package com.asura.bootdubbo.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.asura.ecm.bean.OrderInfo;
import com.asura.ecm.service.UserService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;


@Service//暴露服务 
@Component
public class UserServiceImpl implements UserService {

    /**
     * 获取用户订单数据
     *
     * @param userId
     * @return
     */
    @HystrixCommand
    @Override
    public List<OrderInfo> getUserOrderList(String userId) {
        OrderInfo orderInfo = new OrderInfo();
        orderInfo.setId(1L);
        orderInfo.setName("苹果");
        OrderInfo orderInfo2 = new OrderInfo();
        orderInfo2.setId(2L);
        orderInfo2.setName("香蕉");
        //System.out.println(1/0);//触发consumer层的failback
        return Arrays.asList(orderInfo, orderInfo2);
    }


}
